﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace MyChannel.Library
{
    public class MD5
    {
        public MD5() { }
        public string GetMD5(string _s)
        {
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(_s);
            MD5Managed md5 = new MD5Managed();
            byte[] hash = md5.ComputeHash(bs);
            StringBuilder sb = new StringBuilder();
            foreach (byte b in hash)
            {
                sb.Append(b.ToString("x2").ToUpper());
            }
            return sb.ToString();
        }

        public string GetTime()
        {
            long ticks = DateTime.Now.Ticks;
            ticks = ticks / 10000000;
            return ticks.ToString();
        }

        public string GetBase64(string _s)
        {
            string s = _s.Trim();
            var bytes = Encoding.UTF8.GetBytes(s);
            var base64 = System.Convert.ToBase64String(bytes);
            return base64.ToString();
        }
    }
}
